package com.google.jessewilson.codesearch.ui.tree;

import com.google.jessewilson.codesearch.api.ContentRoot;
import com.google.jessewilson.codesearch.api.ProgrammingLanguage;

/**
 * @author jessewilson
 */
enum Type {

  LANGUAGE {
    public String getDescription(Element element) {
      return ProgrammingLanguage.fromFileName(element.getFile().getPath().getFileName())
          .getName();
    }
  },
  CONTENT_ROOT {
    public String getDescription(Element element) {
      ContentRoot contentRoot = element.getFile().getContentRoot();
      return contentRoot != null ? contentRoot.toString() : "";
    }
  },
  FILE {
    public String getDescription(Element element) {
      return element.getFile().getPath().getFileName();
    }
  },
  LINE {
    public String getDescription(Element element) {
      return element.getLine().getLineValue();
    }
  };

  public abstract String getDescription(Element element);
}
